/****************************************************************************
* MINILOGO - Minimalistic Logo Interpreter
* Copyright (C) 1999-2008 Willian Mitsuda
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
* 
*****************************************************************************

*****************************************************************************
* MINILOGO.C                                                                *
*****************************************************************************
* Ponto de entrada do programa                                              *
****************************************************************************/
#include <grx20.h>   // Funcoes graficas
#include "defines.h" // Definicoes do projeto

// Defines locais...
#define COR_BORDA 7
#define BORDA  29          // Centro do degrade...
#define TITFG  SFG         // Cor do texto da barra de titulo...
#define TITBG  SBG         // Cor do fundo da barra de titulo...
#define TITSTR "Comandos:" // Texto da barra de titulo...

// "Importa" a funcao shell() de SHELL.C...
void shell(void); // Para chamar o shell do MINI-LOGO

/****************************************************************************
* static void initscr(void)                                                 *
*****************************************************************************
* Inicializa a tela do programa                                             *
****************************************************************************/
static void initscr(void)
{
  GrTextOption tit = {&GrFont_PC6x8, {TITFG}, {TITBG}, GR_BYTE_TEXT, GR_TEXT_RIGHT, GR_ALIGN_LEFT, GR_ALIGN_TOP};
  int l;

  // Inicializa o modo grafico...
  GrSetMode(GR_width_height_color_graphics, 640, 480, 256);
  GrSetWindowTitle("Mini-Logo");

  // Desenha a borda...
  for(l = 0; l < 4; l++)
  {
    GrVLine(l, l, 479 - l, COR_BORDA);
    GrVLine(639 - l, l, 479 - l, COR_BORDA);

    GrHLine(l, 639 - l, l, COR_BORDA);
    GrHLine(l, 639 - l, 479 - l, COR_BORDA);
  }

  // Desenha o titulo...
  for(l = 0; l < 4; l++)
  {
    GrHLine(l, 639 - l, MINSY - 4 - l, COR_BORDA);
    GrHLine(l, 639 - l, MINSY - 4 + l, COR_BORDA);

    GrHLine(l, 639 - l, MINSY - 19 - l, COR_BORDA);
    GrHLine(l, 639 - l, MINSY - 19 + l, COR_BORDA);
  }
  GrFilledBox(MINSX, MINSY - 15, MAXSX, MINSY - 8, TITBG);
  GrDrawString(TITSTR, 9, 4, MINSY - 15, &tit);
}

/****************************************************************************
* static void endscr(void)                                                  *
*****************************************************************************
* Encerra o programa                                                        *
****************************************************************************/
static void endscr(void)
{
  // Retorna ao modo texto...
  GrSetMode(GR_80_25_text);
}

/****************************************************************************
* int main()                                                                *
*****************************************************************************
* Ponto de entrada do programa                                              *
****************************************************************************/
int main()
{
  initscr(); // Inicializa modo grafico e desenha a tela principal
  shell();   // Carrega o shell...
  endscr();  // Finaliza o programa...
  return(0); // Sai do programa...
}
